package com.zuoshenge.sys.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zuoshenge.sys.dto.PageRequestDTO;
import com.zuoshenge.sys.entity.User;
import com.zuoshenge.sys.service.UserDataService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserDataService userDataService;

    @PostMapping("/record")
    public ResponseEntity<Object> record(@RequestBody PageRequestDTO pageRequestDTO) {
        IPage<User> userIPage = userDataService.selectPage(pageRequestDTO.getUsername(), pageRequestDTO.getPageNo(), pageRequestDTO.getPageSize());
        Map<String, Object> result = new HashMap<>(3);
        result.put("records", userIPage.getRecords());
        return ResponseEntity.ok(result);
    }
}
